#include <stdio.h> //for printf
#include <stdlib.h> //for exit
#include "stack.h"

int main() {
    stack_t stackA;

    if (init(&stackA, 100) == STACK_FAIL) {
        printf("initial stack error\n");
        exit(1);
    }

    printf("test init function\n");
    printf("stackA.size = %d\n", stackA.size);
    printf("stackA.sp = %d\n", stackA.sp);
    printf("stackA.elements[10] =%d\n", stackA.elements[10]);

    printf("True = %d\n", 0<=1);
    printf("False = %d\n", 0>1);

    //push
    for (int i = 100; i<110; i=i+2) {
        if (push(&stackA, i) != STACK_OK) {
            printf("push error %d\n", i);
        }
        printf("push %d into stack\n", i);
    }

    printf("100 in stack = %d, 200 in stack=%d\n", isExist(&stackA,100), isExist(&stackA, 200));

    //pop

    while(!isEmpty(&stackA)) {
        int x;
        if (pop(&stackA, &x)!= STACK_OK) {
            printf("pop error\n");
        } else {
            printf("pop %d from stack\n", x);
        }
    }

}